import { Controller, Get, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { AuthConfirmEmailDto } from './dto/auth-confirm-email.dto';

import { AuthService } from './auth.service';
import { I18nContext } from 'nestjs-i18n';

@ApiTags('Auth')
@Controller({})
export class ConfirmAuthController {
  constructor(private service: AuthService) {}

  @Get('/confirm-email')
  async openConfirmEmail(@Query() confirmEmailDto: AuthConfirmEmailDto) {
    console.log(confirmEmailDto);
    const i18n = I18nContext.current();
    await this.service.confirmEmail(confirmEmailDto.hash);
    return i18n?.t('confirm-email.confirmMailSuccess');
  }
}
